﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinServer
{
    /// 第六步、定义一个服务对象【类似于服务端】 

    public class HansAppServer : SuperSocket.SocketBase.AppServer<HansAppSession, HansRequestInfo>
    {
        /// 字符编码  

        public static Encoding Encoder = Encoding.GetEncoding("gbk");

        /// 开始标记 如："!Start"
        /// 如果不需要开始标记，请将 开始标记设置为string.Empty。   

        public static string StartMark = "!Start";

        /// 结束标记 如："$End"
        /// 如果不需要结束标记，请将 结束标记设置为string.Empty。     

        public static string EndMark = "$End";

        /// 按照默认的字符编码、开始标记、结束标记实例化服务对象       

        public HansAppServer()

 : base(new HansReceiveFilterFactory(Encoder, StartMark, EndMark))

        {

        }

        /// 按照设置的字符编码、开始标记、结束标记实例化服务对象
        /// 【如果不需要开始标记，请将 开始标记设置为string.Empty。如果不需要结束标记，请将 结束标记设置为string.Empty。】      

        /// <param name="encoder"></param>
        /// <param name="startMark"></param>
        /// <param name="endMark"></param>

        public HansAppServer(Encoding encoder, string startMark, string endMark)
 : base(new HansReceiveFilterFactory(encoder, startMark, endMark))

        {

            HansAppServer.Encoder = encoder;

            HansAppServer.StartMark = startMark;

            HansAppServer.EndMark = endMark;

        }

    }

}
